<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>已付订单</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/ttOrder/static/jquery-easyui-1.3.3/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/ttOrder/static/jquery-easyui-1.3.3/themes/icon.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/ttOrder/static/jquery-easyui-1.3.3/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/ttOrder/static/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/ttOrder/static/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>

<script type="text/javascript">


	function getTotal(){
		$.post("${pageContext.request.contextPath}/ttOrder/getTotal",function(result){
			if(result>0){
				$.messager.alert("恭喜发财","吃了吧公司总收入为 "+result+"￥");
				$("#dg").datagrid("reload");
			}
			else{
				$.messager.alert("再接再厉","还没有收入加油");
			}
		},"json");
	}
	
	
	function formatState(val,row){
		if(val==1){
			return "<font color='red'>VIP客户</font>";
		}
		if(val==0){
			return "<font color='green'>普通客户</font>";
		}
	}
	
	function showOrder(){
		var orderId = $("#s_menuName").val();
		if(orderId == "" ){
			$.messager.alert("系统提示","请输入订单ID");
			return;
		}
		$.ajax({
			type: 'POST',
			url: '${pageContext.request.contextPath }/ttOrder/findOrder',
			data:{
				orderId: orderId
			},
			dataType: 'json',
			success: function(data){
				//判断成功与否
				if(data.success){
					var message = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;菜名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;数量&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;价格";
				 	message = message + "<br>--------------------------------------------";
					var list = data.messageMap.orderDetails;
					for(var i = 0 ; i < list.length ; i++ ){
						message = message + "<p align=right>"+list[i].food.foodName+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+list[i].foodCount+"份&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+"￥"+list[i].foodMoney+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>";
						//alert(list[i].food.foodName + list[i].foodCount + list[i].foodMoney);
						//message = message + "<br>&nbsp;&nbsp;&nbsp;"+list[i].food.foodName+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+list[i].foodCount+"份"+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;￥"+list[i].foodMoney;
					}
					message = message + "--------------------------------------------";
					message = message + "<br>总金额: ￥"+data.messageMap.totalPrice;
					
					$.messager.alert("订单详情",message);
				} 
				else{
					$.messager.alert("系统提示","查询失败，请输入正确订单ID");
				}
			},
			error: function (data) {
				$.messager.alert("系统提示","查询失败!");
			}
		});
		
	}
	
	/*
	function writeBtn(){ 
		return "<a href='javascript:showOrder()' class='easyui-linkbutton l-btn l-btn-plain showOrderBtn' iconcls='icon-remove' plain='true'><span class='l-btn-left'><span class='l-btn-text icon-add l-btn-icon-left'>订单详情</span></span></a>";
	}
	*/
	
</script>
</head>
<body style="margin: 1px">
<table id="dg" title="已付订单" class="easyui-datagrid"
   fitColumns="true" pagination="true" rownumbers="true" checkOnSelect="false" selectOnCheck=""
   url="${pageContext.request.contextPath}/ordered" fit="true" toolbar="#tb">
   <thead>
   	<tr>
   		<th field="id" width="15" align="center">订单Id</th>
   		<th field="tableId" width="15" align="center">桌子Id</th>
   		<th field="userId" width="15" align="center">用户Id</th>
   		<th field="totalPrice" width="25" align="center">总额</th>
   		<th field="vip" width="30" align="center" formatter="formatState">VIP会员</th>
   		<th field="time" width="45" align="center">下单日期</th>
   		<!-- <th field="orderStatus" width="20" align="center" formatter="writeBtn">状态</th> -->
   	</tr>
   </thead>
 </table>
 <div id="tb">
 	<div>
 		<a href="javascript:getTotal()" class="easyui-linkbutton" iconCls="icon-remove" plain="true">总收入</a>
 		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		按订单ID展示详细订单：&nbsp;<input type="text" id="s_menuName" size="20" onkeydown="if(event.keyCode==13) showOrder()"/>
		<a href="javascript:showOrder()" class="easyui-linkbutton " iconCls="icon-search" plain="true">查询</a>
 	</div>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
 </div>
 
 
</body>
</html>